package ${basePackage}.generator.file;

import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.core.io.resource.ResourceUtil;
import ${basePackage}.model.MainTemplateModel;
import freemarker.template.TemplateException;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.Map;

/**
 * @author ${author}
 * @verison  ${version}
 */
public class FileGenerator {
    public static void main(String[] args) throws IOException, TemplateException {
        String projectPath = System.getProperty("user.dir");

    }


    public static void doGen(Object model) throws TemplateException, IOException {

        // 输入输出根路径
        String inputRootPath = "${fileConfig.sourceRootPath}";
        String outputRootPath = System.getProperty("user.dir") + "${fileConfig.outputRootPath}";

        // 输入输出文件
        String inputPath;
        String outputPath;

        <#list fileConfig.files as file>
            inputPath = new File(inputRootPath, "${file.inputPath}").getAbsolutePath();
            outputPath =  new File(outputRootPath, "${file.outputPath}").getAbsolutePath();

            <#if file.type == "static">
            StaticGenerator.copyFilesByHutool(inputPath, outputPath);
                <#else>
            DynamicGenerator.doGen(inputPath, outputPath, model);
            </#if>

        </#list>
    }


    public static void doGen(String inputPath, String outputPath, Object model) throws TemplateException, IOException {
        DynamicGenerator.doGen(inputPath, outputPath, model);
    }
}
